﻿#define _CRT_SECURE_NO_WARNINGS  1
//一定要动手，例子不管多么简单，建议至少自己手敲一遍看看是否理解了里头的细枝末节。
//一定要学会思考，思考为什么要这样，而不是那样。还要举一反三地思考
#include<string>
#include<vector>
#include<iostream>
using namespace std;
class Solution {
public:
    /*string str[10] = { "","","abc","def","ghi","jkl","mno","pqrs","tuv","wxyz" };
    void combin(string digits, int index, string cbstr, vector<string>& v)
    {
        if (index == digits.size())
        {
            v.push_back(cbstr);
            return;
        }
        int mark = digits[index] - '0';
        string str2 = str[mark];
        for (auto it : str2)
        {
            combin(digits, index + 1, cbstr + it, v);
        }
    }
    vector<string> letterCombinations(string digits) {
        vector<string> v;
        if (digits.empty())
        {
            return v;
        }
        combin(digits, 0, "", v);
        return v;
    }*/
  /*  vector<vector<int>> generate(int numRows) {
        vector<vector<int>> vv;
        vv.resize(numRows);
        for (int i = 0; i < vv.size(); i++)
        {
            vv[i].resize(i + 1, 0);
            vv[i].front() = vv[i].back() = 1;
        }
        for (int x = 0; x < vv.size(); x++)
        {
            for (int y = 0; y < vv[x].size(); y++)
            {
                if (vv[x][y] == 0)
                {
                    vv[x][y] = vv[x - 1][y - 1] + vv[x - 1][y];
                }
            }
        }
        return vv;
    }

    ﻿int main()
    {
        int ar[] = { 1,2,3,4,5,6,7,8,9,10 };
        int n = sizeof(ar) / sizeof(int);
        vector<int> v(ar, ar + n);
        cout << v.size() << ":" << v.capacity() << endl;
        v.reserve(100);
        v.resize(20);
        cout << v.size() << ":" << v.capacity() << endl;
        v.reserve(50);
        v.resize(5);
        cout << v.size() << ":" << v.capacity() << endl;
    }*/
public:
    int singleNumber(vector<int>& nums) {
        int abs = 0;
        for (int i = 0; i < 32; i++)
        {
            //nums中每个数的第i位求和
            int tatle = 0;
            for (auto it : nums)
            {
                tatle += (it >> i) & 1;
            }
            if (tatle % 3)//如果模3！=0则答案的第i位是1;
            {
                abs |= 1 << i;
            }
        }
        return abs;
    }
};
int main()
{
    vector<int> it{ 2,2,3,2 };
    Solution str1;
    int ret = str1.singleNumber(it);
    return ret;

    system("pause");
    return 0;
}
